import json

from util import httpTool

BASE_PATH = "iot/api/v1/v1/token/"


def refresh(req):
    path = BASE_PATH + "get"
    resStr = httpTool.doPost(path, json.dumps(req))
    if resStr:
        res = json.loads(resStr)
        if res['data'] and res['data']['accessToken']:
            token = res['data']['accessToken']
            httpTool.token = token
    else:
        return None


